Skip to content

feat(health): add daily health summaries aggregated from records - #33

Open
johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-32-daily-health-summaries
Open

johnnyhuy wants to merge 1 commit into
mainfrom
agent/issue-32-daily-health-summaries

Conversation

@johnnyhuy

@johnnyhuy johnnyhuy commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Adds daily aggregation for Apple Health exports. A new Foundation-only DailyHealthSummary value type holds one day of steps, active and basal energy, distance, average and resting heart rate, body mass, and sleep duration, and HealthExport.dailySummaries(calendar:) groups the parsed records by start-of-day and returns summaries sorted by day.

Part of #6. Closes #32.

How it was verified:

  • mise run lint - no violations in the added files. Repo total stays at the pre-existing baseline (503 violations, 11 serious across 126 files, all in existing files). The lint task reports failure on that baseline, same as on origin/main before this change.
  • mise run build - passed.
  • mise run test - passed, 133 tests with 0 failures. The 9 new DailyHealthSummaryTests are listed below.
  • mise run ios:build:dev and mise run ios:test:ui were not run. Nothing user-facing changed; this slice is core aggregation logic only.

Proof, terminal capture from mise run test filtered to the new suite:

Test Case '-[BetterFitTests.DailyHealthSummaryTests testAverageHeartRateAndLatestRestingAndMass]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testCodableRoundTrip]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testDailySummariesFromParsedExport]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testEmptyExportReturnsNoSummaries]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testGroupsRecordsByDayAndSorts]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testMissingKindsStayNil]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testRecordsWithoutStartDateAreSkipped]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testSleepDurationSumsStagesStartingThatDay]' passed.
Test Case '-[BetterFitTests.DailyHealthSummaryTests testSumsStepsEnergyAndDistanceWithNormalisation]' passed.
Executed 133 tests, with 0 failures (0 unexpected)

Each test name states what it shows. Together they cover grouping and sorting by day, summing steps with kilojoule and kilometre normalisation, averaging heart rate, picking the latest resting heart rate and body mass of the day, summing sleep stages, keeping missing kinds nil instead of zero, skipping records without a start date, an empty export, an end-to-end run through HealthExportParser, and a Codable round-trip.

Reviewer notes:

Follow-up verification (2026-11-08, later run):

  • Re-checked locally on the branch tip (503defc, already on origin/main base f74c050, no rebase needed): mise run lint still 503 violations with none in the two added files, mise run build passed, mise run test passed with all 9 DailyHealthSummaryTests green.
  • CI is now fully green. The first Mobile e2e (mobilewright) run failed one test with "app did not come to foreground" plus a WebSocket close, a simulator flake unrelated to this core-only change. Re-running the failed job passed (11m7s), and SwiftPM, iOS xcodebuild, iOS UI tests plus coverage, CodeQL, and Socket checks all pass. Merge state is CLEAN.
  • Nothing user-facing changed, so no screenshot evidence applies. This PR is ready for human review and approval.

@johnnyhuy

Copy link
Copy Markdown
Contributor Author

Follow-up verification complete. Local lint, build, and test re-run on 503defc pass with no new lint violations. The flaky Mobile e2e failure was re-run and now passes, so every CI check is green and the merge state is CLEAN. This PR only needs a human approving review now. No new slice was started this run, per the one-agent-PR rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add daily health summaries aggregated from HealthRecord

1 participant